package com.huluobo.a2107kotlinshopping.db

import androidx.room.Dao
import androidx.room.Delete
import androidx.room.Insert
import androidx.room.OnConflictStrategy
import androidx.room.Query
import androidx.room.Update
import com.huluobo.a2107kotlinshopping.login.UserBean

/**
 *  Created by LC on 2023/11/14.
 *  Dao 是数据库转换为对象
 *  主要添加增删改查方法
 */
@Dao
interface UserInfoDao {
    //插入,onConflict插入时的规则,OnConflictStrategy.REPLACE 如果是相同的数据,就替换
    @Insert(onConflict = OnConflictStrategy.REPLACE)
    fun insertUserInfo(userBean: UserBean)

    @Update
    fun updateUserInfo(userBean: UserBean)

    @Query("select * from user_info where id =:userId")
    fun queryUserInfo(userId: Int): UserBean

    @Delete
    fun deleteUserInfo(userBean: UserBean)
}